package edu.avans.hartigehap.repository;

import java.util.Date;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.joda.time.DateTime;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.PagingAndSortingRepository;
import edu.avans.hartigehap.domain.*;

public interface DiscountRepository extends PagingAndSortingRepository<Discount, Long> {

	//get all discounts (needed for chosing a discount that could be set to active)
	//public List<Discount> findAll();
	
	//show active discount
	//in the database this is a tinyint worth 0 or 1
	public List<Discount> findByActive(Boolean active);
}
	
	//show discounts of type X
	//discount doesnt have a type, so it doesnt work -)
	//public List<Discount> findByType(String Type);
	
	
	//---------------------- Example ----------------------
	//@PersistenceContext
	//private EntityManager em;
	// this is a custom method for which Spring cannot create an implementation
	// so we need to make our own repository implementation!
	//public List<Order> findSubmittedOrdersForRestaurant(Restaurant restaurant) {
	//	return em.createNamedQuery("Order.findSubmittedOrders", Order.class).
	//			setParameter("restaurant", restaurant).getResultList();		
	//}
